{% extends "BlackhouseappBluehouseappBundle:layout:layout.html.twig" %}
{% block title %}
    节点管理
{% endblock %}
{% block body -%}
    <div class="page-header">
        <h2>节点管理 <small></small></h2>
    </div>
    <ol class="breadcrumb clearfix">
        <div class="clearfix">
            <div class="pull-left">
                <a href="{{path('admin_node_new')}}"><button class="btn btn-primary">创建</button></a>
            </div>
        </div>
    </ol>


    <table class="table  table-striped table-hover table-condensed">
        <thead>
            <tr>

                <th>名称</th>
                <th>代码</th>
                <th>头像</th>
                <th>描述</th>
                <th>状态</th>
                <th>显示序号</th>
                <th>所属分类</th>
                <th>最后更新时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        {% for entity in entities %}
            <tr>
                <td><a href="{{ path('admin_node_show', { 'id': entity.id }) }}">{{ entity.name }}</a></td>
                <td>   {{ entity.code }}
                </td>
                <td>
                {% if entity.attachment %}
                <img  class="box_avatar" border="0"  align="default" src="{{vich_uploader_asset(entity,'image')|imagine_filter('avatar_image')}}"/>
                {% endif %}
                </td>
                <td>
                    {{ entity.description }}
                </td>
                <td>
                {% if entity.enabled %}
                    <span class="label label-success">正常</span>
                {% else %}
                    <span class="label label-danger">已禁用</span>
                {% endif %}
                </td>
                <td>{{ entity.no }}</td>
                <td>{{ entity.category.name }}</td>
                <td>{% if entity.modified %}{{ entity.modified|date('Y-m-d H:i:s') }}{% endif %}</td>
                <td>
                <ul>

                    <li>
                        <a href="{{ path('admin_node_edit', { 'id': entity.id }) }}">编辑</a>
                    </li>

                    <li>
                    {% if entity.enabled %}
                        <a href="{{path('node_disable',{id:entity.id})}}"
                           onclick="return confirm('您确定禁用{{entity.name}}吗？')">
                            禁用
                        </a>

                    {% else %}
                        <a href="{{path('node_enable',{id:entity.id})}}"
                           onclick="return confirm('您确定启动{{entity.name}}吗？')">
                            启用
                        </a>
                    {% endif %}
                    </li>
                    <li>

                        <a href="{{path('admin_node_delete',{id:entity.id})}}"
                           onclick="return confirm('您确定要删除{{entity.name}}吗？')">
                            删除
                        </a>


                    </li>
                </ul>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

    {{ knp_pagination_render(entities) }}
    {% endblock %}
